{include file="public/toper" /}
<script type="text/javascript" src="/static/js/myajax.js"></script>
<style>
    .layui-table-cell {
        font-size:14px;
        padding:0 5px;
        height:auto;
        overflow:visible;
        text-overflow:inherit;
        white-space:normal;
        word-break: break-all;
    }
</style>
<div class="x-nav">
    <span class="layui-breadcrumb">
        <a href="">订单管理</a>
        <a href="">订单列表</a>
    </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon" style="line-height:30px">&#xe666;</i></a>
</div>
<div class="x-body">
    <div class="layui-row">
        <div class="layui-form layui-col-md12 x-so">
            <input type="text" name="sreach" value=""  style="width:250px;" id="key"   placeholder="请输入收货人名称/地址/电话/订单号" autocomplete="off" class="layui-input">
            <div class="layui-input-inline">
                <select name="order_type" id="order_type">
                    <option value="0">全部</option>
                    <option value="2">销售订单</option>
                    <option value="1">会员订单</option>
                </select>
            </div>
            <div class="layui-input-inline">
                <select name="store" id="storeId">
                    <option value="0">全部</option>
                    {volist name="store" id="vo"}
                    <option value="{$vo.store_id}">{$vo.name}</option>
                    {/volist}
                </select>
            </div>
            <div class="layui-input-inline">
                <select name="order_status" id="order_status">
                    <option value=".">全部</option>
                    <option value="0">未支付</option>
                    <option value="1">已支付</option>
                    <option value="2">已发货</option>
                    <option value="3">已完成</option>
                    <option value="4">已取消</option>
                    <option value="5">归还中</option>
                    <option value="6">店铺已收货</option>
                    <option value="7">已验收</option>
                    <option value="8">待用户确认</option>
                    <option value="9">待用户支付</option>
                    <option value="10">租赁中</option>
                </select>
            </div>
            <button class="layui-btn" id="search"><i class="layui-icon">&#xe615;</i></button>
        </div>
    </div>

    <table class="layui-hide" id="test" lay-filter="test"></table>
</div>
<script type="text/html" id="sn">
    <div><a href="#"  onclick="x_admin_show('查看订单','{:url(\'Order/order_details\')}?id={{d.order_id}}')" title="查看详情" class="layui-table-link">{{d.order_sn}}</a></div>
    <div>{{#  if(d.type==1){ }}
        会员订单
        {{#  } else if(d.type==2) { }}
        销售订单
        {{#  } }}
    </div>
</script>
<script type="text/html" id="shou">
    {{#  if(d.order_type==1){ }}
    【快递】：{{d.name}},{{d.phone}}
    <span>{{d.consignee}}</span>
    {{#  } else if(d.order_type==2) { }}
    【自提】：{{d.sname}},{{d.sphone}}<span>{{d.saddress}}</span>
    {{#  } }}
</script>
<script type="text/html" id="sj">
    <div>{{d.uname}}</div>
    <div>{{layui.util.toDateString(d.add_time*1000) }}</div>
</script>
<script type="text/html" id="goodsp">
    <div>{{d.goods_price}}</div>
    {{# if(d.type==1){ }}<div>邮费：{{d.postage}}</div><div>押金：{{d.deposit_price}}</div>{{#} }}
</script>
<script type="text/html" id="payp">
    <div>{{d.pay_price}}</div>{{# if(d.type==1){ }}<div>邮费：{{d.postage}}</div><div>押金：{{d.deposit_price}}</div> {{#} }}
</script>
<script>
    layui.use(['table','upload','util'], function(){
        var table = layui.table, $ = layui.jquery;
        var layer = layui.layer;
        var loading = layer.load(1, {shade: [0.1,'#fff'] });

        var name = '{$name}';
        $('#key').val(name);

        var tableIn = table.render({
            where: {key: $('#key').val()}
            ,method: 'post',
            elem: '#test'
            ,url: "{:url('Order/index')}"
            ,id:'test'
            ,cols: [[
                {field:'order_id', width:80, title: '序号',align: 'center',type:'numbers'}
                ,{field:'order_sn', width:180, title: '订单号',align: 'center',templet:'#sn'}
                ,{field:'sname',width:200,title: '门店',align: 'center'}
                ,{width:300,title: '收货信息',align: 'center',templet: '#shou'}
                ,{field:'order_status', width:100, title: '订单状态',align: 'center',templet: function(d){
                        if(d.order_status==0){
                            return '未支付';
                        }else if(d.order_status==1){
                            return '已支付';
                        }else if(d.order_status==2){
                            return '已发货';
                        }else if(d.order_status==3){
                            return '已完成';
                        }else if(d.order_status==4){
                            return '已取消';
                        }else if(d.order_status==5){
                            return '归还中';
                        }else if(d.order_status==6){
                            return '店铺已收货';
                        }else if(d.order_status==7){
                            return '已验收';
                        }else if(d.order_status==8){
                            return '待用户确认';
                        }else if(d.order_status==9){
                            return '待用户支付';
                        }else if(d.order_status==10){
                            return '租赁中';
                        }
                }}
                ,{width:130,title:'订单金额',align:'center',templet:'#goodsp'}
                ,{width:130,title:'实付金额',align:'center',templet:'#payp'}
                ,{width: 180,align:'center', sort:'true',title: '下单时间', templet: '#sj'}
            ]]
            ,page: true
            ,limit: 30
            ,limits:[30,60,90,120,150,180,210,240,270,300]
        });
        layer.close(loading);

        //搜索
        $('#search').on('click', function () {
            var loading = layer.load(1, {shade: [0.1,'#fff'] });
            tableIn.reload({
                where: {key: $('#key').val(),sotre_id:$('#storeId').val(),order_status:$('#order_status').val(),order_type:$("#order_type").val()}
                ,page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
            layer.close(loading);
        });
    });
</script>
{include file="public/footer"/}